Proxy Config
Cross Origin issues are a pain that we usually encounter in development environments.
- A local API server uses another domain or port, not an issue if you have CORS setup
- A local server might be hosting an embedded frame
To this goal, you can route requests through the App's Webpack Dev Server instance, by matching a request's path to a domain.
The extent of configuration is better explained in the underlying http-proxy-middleware, but common configuration is covered below.
// .plzrc.js
module.exports = {
proxy: {
{
'/api/v1': { target: 'http://localhost:8080' } /*
\_____/ \_______________________________/
| |
context options */
}
}
}
This will proxy the following shaped requests from the Webpack Dev Server to the "target" and back: http://localhost:3000/api/v1/accounts → http://localhost:8080/api/v1/accounts